package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealOverViewVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


import java.util.List;

@Mapper
public interface SetmealMapper {

    @Select("select count(id) from setmeal where category_id = #{category_id} ")
    Integer getDishBySetmealId(Integer category_id);

    List<Long> getSetmealAndDishById(List<Long> ids);

    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getSetmealDishById(Integer id);

    Page<SetmealVO> pageSearch(SetmealPageQueryDTO setmealPageQueryDTO);
    
    @Select("select * from setmeal where id = #{id};")
    SetmealVO getSetmealById(Integer id);
    
    @AutoFill(value = OperationType.INSERT)
    void insertSetmeal(Setmeal setmeal);

    void insertBatch(List<SetmealDish> setmealDishes);

    void updateSetmeal(Setmeal setmeal);

    void deleteSetmeal(List<Long> ids);

    Long getSetmealStatusById(List<Long> ids);

    void deletSetmealDishesById(List<Long> ids);

    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> getSetmealCategoryId(String categoryId);

    SetmealOverViewVO getSetmealStatus();

}
